<?php
include_once '../inc/config.inc.php';
include_once '../inc/mysqli.inc.php';
include_once '../inc/tool.inc.php';
//var_dump($_SERVER); exit();
$link=connect();
if(isset($_POST['submit'])){
    $cheekflag='cm_add';
include_once 'inc/checkinfo.inc.php';
    $query="insert into childModule(referid,moduleName,info,memberid,sort) values('{$_POST['referid']}','{$_POST['moduleName']}','{$_POST['info']}','{$_POST['memberid']}',{$_POST['sort']})";
    $result=execute($link,$query);
    if(mysqli_affected_rows($link)){
        skip('childModuleAdd.php','ok','添加成功！');
    }
    else{
        skip("$_SERVER[REQUEST_URI]",'error','添加失败，请重试！ ');
    }
}

?>
<?php
$template='添加子板块';
include_once 'inc/header.inc.php';
?>
 <div id="main">
        <div class="intro"><?php echo $template ?></div>  
        <form method="post">   
            <table class="au"> 
                <tr>
                    <td>所属父板块</td>
                    <td>
                        <select name="referid">
                        <option value="0">=========请选择一个父板块=========</option>
                        <?php 
                            $query="select *from fatherModule";
                            $result=execute($link,$query);
                            while($data=mysqli_fetch_assoc($result)){
                                $data=dehtml($data);
                               echo "<option value='{$data['id']}'>{$data['moduleName']}</option>"; 
                            }
                        ?>
                        </select>
                    </td>
                    <td><span>* 请选择一个父板块</span></td>
                </tr>
                <tr>
                    <td>子板块名称</td>
                    <td><input type="text" name="moduleName" ></td>
                    <td><span>* 板块名称不得为空，最大不超过40个字符</span></td>
                </tr>
                <tr>
                    <td>&nbsp;&nbsp;板块简介</td>
                    <td><textarea name="info"></textarea></td>
                    <td><span>内容最大不超过255个字符</span></td>
                </tr>
                <tr>
                    <td>&nbsp;&nbsp;版&nbsp;&nbsp;&nbsp;&nbsp;主&nbsp;&nbsp;</td>
                    <td>
                        <select name="memberid">
                        <option value="0">=======请选择一个会员作为版主=======</option>
                        <?php   
                            $query="select *from member";
                            $result=execute($link,$query);
                            while($data=mysqli_fetch_assoc($result)){
                                $data=dehtml($data);
                               echo "<option value='{$data['id']}'>{$data['name']}</option>"; 
                            }
                        ?>
                        </select>
                    </td>
                    <td><span>选择一个会员作为版主</span></td>
                </tr>
                <tr>
                    <td>&nbsp;&nbsp;&nbsp;&nbsp;排&nbsp;&nbsp;&nbsp;&nbsp;序</td>
                    <td><input type="text" value="0" name="sort" ></td>
                    <td><span>* 填写一个数字</span> </td>
                </tr>
            </table>
            <input type="submit" name="submit" value="添加" class="nsubmit" />
        </form>
    </div>

<?php
    include_once 'inc/footer.inc.php';
?>
